package cn.kami.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import cn.kami.dao.IBatteryStationDAO;
import cn.kami.vo.BatteryStation;

public class BatteryStationDAOImpl implements IBatteryStationDAO {
	
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	public BatteryStationDAOImpl(Connection conn){
		this.conn = conn;
	}
	@Override
	public List<BatteryStation> findAllStationName() throws Exception {
		// TODO Auto-generated method stub
		List<BatteryStation> all = new ArrayList<BatteryStation>();
		String sql = "SELECT bs_name,bs_id FROM batteryStation";
		this.pstmt = this.conn.prepareStatement(sql);
		ResultSet rs = this.pstmt.executeQuery();
		BatteryStation batStation = null;
		while(rs.next()){
			batStation = new BatteryStation();
			batStation.setBsName(rs.getString(1));
			batStation.setBsID(rs.getString(2));
			all.add(batStation);
		}
		this.pstmt.close();
		return all;
	}

}
